/**
 * 1.声明一个面积接口AreaInterface 声明面积方法area
 *2.声明两个类
 */
// 定义 AreaInterface  接口
interface AreaInterface  {
    double area();
}

// 长方形类实现 Shape 接口
class Rectangle implements AreaInterface  {
    private double width;
    private double height;

    public Rectangle(double width, double height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public double area() {
        return width * height;
    }
}

// 圆形类实现 Shape 接口
class Circle implements AreaInterface  {
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    @Override
    public double area() {
        return Math.PI * radius * radius;
    }
}

// 测试代码
public class d5 {
    public static void main(String[] args) {
        AreaInterface  rectangle = new Rectangle(3, 4);
        System.out.println("长方形的面积为：" + rectangle.area());

        AreaInterface  circle = new Circle(5);
        System.out.println("圆形的面积为：" + circle.area());
    }
}
